<?php
require_once 'WxCreateTempleat.class.php';

/**
 * 微信消息功能类
 * Class WxMessage
 */
class WxMessage extends WxCreateTempleat{

    function __construct($appId, $appSecret)
    {
        parent::__construct($appId, $appSecret);
    }

    /**
     * 个人消息
     * @param $openid
     * @param string $msg
     * @param string $url
     */
    public function sendNotice($openid,$msg = '',$url = ''){

        //echo '发送推送notice'.$openid;
        //$this->sendMsgTemplate($this->GetTemplate());
    }

    /**
     * 订单消息
     * @param $openid
     * @param string $msg
     * @param string $url
     */
    public function sendOrderMsg($openid,$msg = '',$url = ''){
        //echo '发送推送msg'.$openid;
        //$this->sendMsgTemplate($this->GetTemplate());
    }
    
    /**
     * 投标成功发布消息
     * @param unknown $openid
     * @param unknown $url
     * @param unknown $tenderId
     * @param unknown $code
     * @param unknown $amount
     * @param unknown $remark
     * @return mixed
     */
    public function tbSuccess($openid,$url,$code,$amount,$remark){
        $this->SetOpenid($openid);
        $this->SetUrl($url);
        $this->SetParam('first', '有人参与了您的竞标');//标题
        $this->SetParam('keyword1', $code);//投的编号
        $this->SetParam('keyword2', '¥'.$amount);//投标金额
        $this->SetParam('keyword3', date('Y年m月d日'));//投标时间
        $this->SetParam('remark', $remark);//备注信息
        $this->SetTemplateId('L2k4dCezf4jQtawCYPzUSqEgiCP7HEPGAaLn06M8ZVQ');
        return json_decode($this->sendMsgTemplate($this->GetTemplate()),true);
    }
    
    /**
     * 项目进度通知
     * @param unknown $openid
     * @param unknown $url
     * @param unknown $title
     * @param unknown $code
     * @param unknown $msg
     * @param unknown $remark
     * @return mixed
     */
    public function jDMsg($openid,$url,$title,$code,$msg,$remark){
        $this->SetOpenid($openid);
        $this->SetUrl($url);
        $this->SetParam('first', $title);//标题
        $this->SetParam('keyword1', $code);//项目名称
        $this->SetParam('keyword2', $msg);//投标进度
        $this->SetParam('keyword3', '具体详情点击前往查看');//具体详情
        $this->SetParam('remark', $remark);//备注信息
        $this->SetTemplateId('euYQ_u_JXetRC2Z8dzIZoe9G1DVGRIOBrdJS7rVAoRM');
        return json_decode($this->sendMsgTemplate($this->GetTemplate()),true);
    }
    
    /**
     * 新贷款申请通知
     * @param unknown $openid
     * @param unknown $url
     * @param unknown $title
     * @param unknown $name
     * @param unknown $amount
     * @param unknown $limit
     * @param unknown $remark
     * @return mixed
     */
    public function dKMsg($openid,$url,$title,$name,$amount,$limit,$remark){
        $this->SetOpenid($openid);
        $this->SetUrl($url);
        $this->SetParam('first', $title);//标题
        $this->SetParam('keyword1', $name);//产品名称
        $this->SetParam('keyword2', $amount);//额度
        $this->SetParam('keyword3', $limit);//期限
        $this->SetParam('remark', $remark);//备注信息
        $this->SetTemplateId('LZyse3cuyduwwi-Kc4DVxm3eMzZlBUxTJV632nWamH4');
        return json_decode($this->sendMsgTemplate($this->GetTemplate()),true);
    }
    
    /**
     * 贷款申请已经被受理
     * @param unknown $openid
     * @param unknown $url
     * @param unknown $name
     * @param unknown $code
     * @param unknown $remark
     * @return mixed
     */
    public function jdShouli($openid,$url,$name,$code,$remark){
        $this->SetOpenid($openid);
        $this->SetUrl($url);
        $this->SetParam('first', '您好，贷款申请已经被受理');//标题
        $this->SetParam('keyword1', $name);//产品名称
        $this->SetParam('keyword2', $code);//额度
        $this->SetParam('keyword3', date('Y年m月d日 H:i:s'));//期限
        $this->SetParam('remark', $remark);//备注信息
        $this->SetTemplateId('5lyFat57D4mDZg_2-vSnfLBgIq0Yxiy-iaNXYEG3dZ4');
        return json_decode($this->sendMsgTemplate($this->GetTemplate()),true);
    }
    
}